#include <stdio.h>

union
{
	short val;
	char union_byte[sizeof(short)];//share memory with val
}testEndian;

int main()
{
	testEndian.val = 0x1234;
	if(testEndian.union_byte[0] == 0x12)
		printf("little endian!");
	else if(testEndian.union_byte[0] == 0x34)
		printf("big endian!");
	else
		printf("error!");
	return 0;
}